<?php

require_once dirname(__FILE__).'/../config.php';
require_once cf\Config::path.'param.php';
require_once cf\Config::path.'user.php';
require_once cf\Config::path.'image.php';

if (cf\Config::use_imagemagick) {
	cf\Image::$USE_IMAGEMAGICK = true;
}

function forward($url) {
	session_write_close();
	header("Location: $url");
	exit;
}

$user = cf\User::getLoggedIn();
if (!$user && !defined('NO_AUTH')) {
	forward('login.php');
}

if (!defined('SMARTY_DIR')) {
	define('SMARTY_DIR', cf\Config::smarty_dir);
}

require_once SMARTY_DIR.'Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;

$smarty->addPluginsDir(cf\Config::path.'components/');

date_default_timezone_set('Europe/Moscow');

$smarty->assign('user',$user);

$smarty->assign('siteName',cf\Config::site);


function show($template, $name, $crumbs=array(), $title='', $keywords='', $descr='')
{
	global $smarty, $lang;

	$smarty->assign('name',$name);
	$smarty->assign('crumbs',$crumbs);
	$smarty->assign('title',$title);
	$smarty->assign('keywords',$keywords);
	$smarty->assign('descr',$descr);
	
	$smarty->assign('tpl', "$template.tpl");

	$smarty->display('main.tpl');
}

?>